<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>03_姓名案例_计算属性</title>
    <script src="../js/vue.js"></script>
</head>
<body>
  <div id="root">
    姓:<input type="text" v-model="firstname"><br>
    名:<input type="text" v-model="lastname"><br>
    全名:<span>{{fullName}}</span>
  </div>
  <script>
    Vue.config.devtools = true;
    Vue.config.productionTip = false;
    const vm = new Vue({
      el:'#root',
      data:{
        firstname:'张',
        lastname:'三'
      },
      computed:{
          //只有只读属性才能简写 直接写成一个方法(当getter用)   省略setter
          fullName() {
              return this.firstname + '-' + this.lastname;
          }
      }
    });
  </script>
</body>
</html>